package com.gangan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gangan.mapper.DoctorMapper;
import com.gangan.model.Doctor;
import com.gangan.model.view.DoctorView;
import com.gangan.service.IDoctorService;
import javafx.scene.control.Pagination;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2019-09-04
 */
@Service("doctorService")
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements IDoctorService {

    @Autowired
    DoctorMapper doctorMapper;

    //医生列表分页查询，模糊字段name
    public IPage<Doctor> pageAndLikeName(IPage<Doctor> page,String name) {
        if (StringUtils.isEmpty(name)){
            return page(page);
        }
        LambdaQueryWrapper<Doctor> like = new QueryWrapper<Doctor>().lambda().like(Doctor::getName, name);
        return page(page, new QueryWrapper<Doctor>().lambda().like(Doctor::getName,name));
    }

    /**
     * 修改医生在职停职状态
     * @param id
     * @param isSuspension
     */
    @Override
    public void isSuspension(Integer id, Boolean isSuspension) {
        doctorMapper.isSuspension(id, isSuspension);
    }
}
